import { getKeyValue, getSearch } from "@/api";

const state = {
  keyValue: [],
};

const actions = {
  async searchListHot({ state, commit, dispatch }) {
    let result = await getKeyValue();
    console.log(result, 111);
    // 如果返回的数据成功了
    if (result.code == 200) {
      commit("SEARCHLISTHOT", result.data.hotKeywordVOList);
      return "ok";
    } else {
      return Promise.reject();
    }
  },
  // 实时关键字
  async searchValue({ state, commit, dispatch }, value) {
    let result = await getSearch(value);
    console.log(result, 888)

  }
};
const mutations = {
  SEARCHLISTHOT(state, data) {
    state.keyValue = data;
  },
};
const getters = {};

// 对外暴露小仓库
export default {
  state: state,
  actions,
  mutations,
  getters,
  namespaced: true,
};
